﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="instructions.aspx.cs" Inherits="member_instructions" %>

    <link rel="stylesheet" href="/Public/Home/css/colorbox.css" />
    <style type="text/css">
    .QiyeC a{border:1px solid #d2ccc4;color:#666;padding: 3px 10px;display:inline-block;margin:5px 0;}
    .box
    {
      display:block;
      width:100%;
      height:400px;
      position: relative;
    }
    #result .setit td{height:20px;}
    .image td{position:relative;}
    .image td a.next,.image td a.previous{
	    position:absolute;top:50%;display:block;width:28px; height:65px; text-indent:-9999px;margin-top:-32px;z-index:9999;
    }
    .image td a.next{right:0;background:url(/Public/Home/images/controls.png) no-repeat bottom right;}
    .image td a.previous{left:0;background:url(/Public/Home/images/controls.png) no-repeat bottom left;}
    .sebig input{margin:0 10px 0 10px;display:inline;background:#fff; border:1px solid #eee;height:33px;line-height:33px;padding:0 5px;width:200px;}
    </style>
 <form id="form1" runat="server" onkeydown="if(event.keyCode==13)return false;">
<div class="Member_content">
	<h1 class="member_iconTit">
    	批件批量上传<asp:Literal ID="Literal1" runat="server"></asp:Literal>
    </h1>
    <h2 class="jies">说明：
    <br />1、文件批量上传，报告文件命名方式为【药品编号_文件 类型,如：95241_说明书.jpg】。
    <br />2、未匹配上的报告图片需在以下列表手动匹配。
    </h2>
    <div class="msearch" style="height:40px;">
        	<input type="button" class="msbut upload" data-type="file" value="文件批量上传">
			<div style="line-height: 35px;font-size: 16px;float:right;">共<b style="color:#F00;margin:0 3px;"><asp:Literal ID="LiteralCount" runat="server"></asp:Literal></b>张图片未匹配</div>
            <span class="s1">
			<b>上传时间</b>
				<input type="text" value="" name="t" id="d4311" style="width:68px;" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')||\'%y-%M-%d\'}'})" placeholder="上传时间" />
			<span style="line-height:30px;margin:0;"> - </span>
				<input type="text" value="" name="te" id="d4312" style="width:68px;" onClick="WdatePicker({ minDate: '#F{$dp.$D(\'d4311\')}', maxDate: '%y-%M-%d' });" placeholder="上传时间" />
			</span>
			<input type="submit" class="msbut" data-type="0" value="搜索">

    </div>
    <div class="mbig">
        <asp:literal ID="ResultDeBug" runat="server"></asp:literal>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" RowStyle-CssClass="searli image" FooterStyle-CssClass="searli" AllowPaging="true"
             PageSize="1" CssClass="sebig" ShowHeader="false" onpageindexchanging="GridView1_PageIndexChanging">
            <Columns>                
            <asp:TemplateField HeaderText="图片">
                            <ItemTemplate>                               
                         <asp:LinkButton ID="LinkButtonPreviousPage" CssClass="previous" runat="server" CommandArgument="Prev" CommandName="Page">上一页</asp:LinkButton>
                           <div id="viewer" class="box" data-url="<%# Eval("url") %>"></div>
                         <asp:LinkButton ID="LinkButtonNextPage" CssClass="next" runat="server" CommandArgument="Next" CommandName="Page">下一页</asp:LinkButton> 
                            </ItemTemplate>
            </asp:TemplateField>
            </Columns>
            <PagerTemplate>
                                    <!--
	        <asp:LinkButton ID="LinkButtonPreviousPage" CssClass="previous" runat="server" CommandArgument="Prev" CommandName="Page" Visible='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>'>上一页</asp:LinkButton>
            <asp:LinkButton ID="LinkButtonNextPage" CssClass="next" runat="server" CommandArgument="Next" CommandName="Page" Visible='<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>'>下一页</asp:LinkButton>       
                                -->
                                </PagerTemplate>
            
        </asp:GridView>
	   <table width="100%" border="0" cellspacing="0" cellpadding="0"  class="sebig">
           <asp:Literal ID="BaseCon" runat="server"></asp:Literal>
		  <tr class="searli">
		    <td colspan="4">
		    	<div id="loadding" style="display:none;">
		    		<img src="/Public/Home/lhgdialog/skins/icons/loading.gif" style="vertical-align:middle;margin-right:15px;" />数据匹配中...
		    	</div>
		    	<div id="result">
		    	</div>
		    </td>
		  </tr>
		  		</table>
	        
  </div>
</div>
        </form>
<script src="/Public/Home/js/jqueryui.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.mousewheel.min.js" type="text/javascript"></script>
<script src="/Public/Home/js/jquery.iviewer.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/Public/Home/js/My97DatePicker/WdatePicker.js"></script>
	<script src="/Public/Home/js/jquery.colorbox.js" type="text/javascript"></script>
    
<script type="text/javascript">
    $(function () {
        /*
         $('.view').colorbox({width:'80%',height:'100%',current: "{current}/{total}"});
         $(document).bind('cbox_complete', function(){
         $("#cboxLoadedContent img").smartZoom();
         });
         */
        var $viewer = $('#viewer');
        var image_url = $viewer.attr('data-url');
        $viewer.iviewer({
            src: image_url, onFinishLoad: function () {
                $viewer.iviewer('set_zoom', 100, true, { x: 0, y: 50 });
            }
        });

        $(".upload").on('click', function () {
            var title, url, $obj = $(this);
            var width = 1000;
            var height = 546;
            if ($obj.attr('data-type') == 'file') {
                title = '批件批量文件上传';
                url = '/base/instructionsupload.aspx';
                width = 840;
                height = 510;
                $.dialog({
                    title: title,
                    width: width,
                    height: height,
                    content: 'url:' + url,
                    padding: 0,
                    lock: true,
                    fixed: true,
                    min: false,
                    max: false
                });
            } else if ($obj.attr('data-type') == 'scan') {
                var width = 1000;
                var height = 543;
                title = '批件批量扫描上传';
                url = '/uploader/dynamsoft/type/instructionsupload.html';
                $.dialog({
                    title: title,
                    width: width,
                    height: height,
                    content: 'url:' + url,
                    padding: 0,
                    lock: true,
                    fixed: true,
                    min: false,
                    max: false,
                    close: function () {
                        if (this.iframe.contentWindow.dcsObject) {
                            this.iframe.contentWindow.dcsObject.destroy();
                        }
                    }
                });
            }
            return false;
        });
        $(document).keyup(function (e) {//捕获文档对象的按键弹起事件
            if (e.keyCode == 13) {//按键信息对象以参数的形式传递进来了
                //var id = $(this).attr('data-id');
                var id = $(".matching").attr('data-id');
                var drug_name = $('#drug_name').val();
                var drug_changjia = $('#drug_changjia').val();
                var wjtype = $('#wjtype').val();
                if (drug_name.length == 0 && drug_changjia.length == 0) {
                    $.dialog.tips('药品名称、规格和生产厂家不能', 1, 'error.gif', function () {
                        $('#drug_name').focus();
                    });
                    return false;
                }
                $('#loadding').show();
                $('#result').html('');
                $.ajax({
                    url: '/member/instructionsmatching.ashx',
                    type: "post",
                    data: { id: id, drug_name: drug_name, drug_changjia: drug_changjia, wjtype: wjtype },
                    dataType: 'json',
                    success: function (data) {
                        $('#loadding').hide();
                        if (data.code == 1) {
                            $('#result').html(data.html);
                            $('.views').colorbox({ width: '80%', height: '100%', current: "{current}/{total}" });
                            return false;
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                            return false;
                        }
                    },
                    error: function () {
                        $('#loadding').hide();
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
                return false;
            }
            });

        $('.matching').on('click', function () {
            var id = $(this).attr('data-id');
            var drug_name = $('#drug_name').val();
            var drug_changjia = $('#drug_changjia').val();
            var drug_rule = $('#drug_rule').val();
            var wjtype = $('#wjtype').val();
            if (drug_name.length == 0 && drug_changjia.length == 0 && drug_rule.length == 0) {
                $.dialog.tips('药品名称、规格和生产厂家不能', 1, 'error.gif', function () {
                    $('#drug_name').focus();
                });
                return false;
            }
            $('#loadding').show();
            $('#result').html('');
            $.ajax({
                url: '/member/instructionsmatching.ashx',
                type: "post",
                data: { id: id, drug_name: drug_name, drug_changjia: drug_changjia, drug_rule: drug_rule, wjtype: wjtype },
                dataType: 'json',
                success: function (data) {
                    $('#loadding').hide();
                    if (data.code == 1) {
                        $('#result').html(data.html);
                        $('.views').colorbox({ width: '80%', height: '100%', current: "{current}/{total}" });
                        return false;
                    } else {
                        $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        return false;
                    }
                },
                error: function () {
                    $('#loadding').hide();
                    $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                }
            });
            return false;
        });
        $('#result').on('click', 'a.save', function () {
            var batch_id = $(this).attr('data-id');
            var image_id = $(this).attr('data-img');
            var save_way = $(this).attr('data-way');
            var dataxk = $(this).attr('data-xk');
            $.dialog.tips('数据提交中,请稍等...', 100, 'loading.gif');
            $.ajax({
                url: '/member/save.ashx',
                type: "post",
                data: { batch_id: batch_id, image_id: image_id, save_way: save_way, dataxk: dataxk },
                dataType: 'json',
                success: function (data) {
                    if (data.code == 1) {
                        $.dialog.tips(data.msg, 1, 'success.gif', function () {
                            window.location.href = '/member/instructions.aspx';
                        });
                        return false;
                    } else {
                        $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        return false;
                    }
                },
                error: function () {
                    $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                }
            });
            return false;
            return false;
        });

        $('.delete').on('click', function () {
            var image_id = $(this).attr('data-id');
            $.dialog.confirm('确定要删除该图片吗？', function () {
                $.dialog.tips('图片删除中,请稍等...', 100, 'loading.gif');
                $.ajax({
                    //url: '/member/instructions/act/delete.html',
                    url: '/member/delfile.ashx',
                    type: "post",
                    data: { image_id: image_id },
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1) {
                            $.dialog.tips(data.msg, 1, 'success.gif', function () {
                                window.location.href = '/member/instructions.aspx';
                            });
                            return false;
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                            return false;
                        }
                    },
                    error: function () {
                        $('#loadding').hide();
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
            });
            return false;
        });
    });
</script>
<script type="text/javascript">
    $(document).ready(window.onresize = function () {
        //var whe = $(window).height();
        //$(".Member_left").css("height",whe-72);
        $('body').on('click', '.ajax-url', function () {
            var msg = '确定要执行该操作吗？';
            var url = $(this).attr('href');
            if ($(this).attr('data-msg')) {
                msg = $(this).attr('data-msg');
            }
            $.dialog.confirm(msg, function () {
                $.ajax({
                    url: url,
                    type: "post",
                    data: {},
                    dataType: 'json',
                    success: function (data) {
                        if (data.code == 1) {
                            $.dialog.tips(data.msg ? data.msg : '操作成功', 2, 'success.gif', function () {
                                window.location.reload();
                            });
                        } else {
                            $.dialog.tips(data.msg ? data.msg : '抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                        }
                    },
                    error: function () {
                        $.dialog.tips('抱歉，系统错误，请稍后再试！', 2, 'error.gif');
                    }
                });
            });
            return false;
        });
        $('.logout').on('click', function () {
            var href = $(this).attr('href');
            $.dialog.confirm('您确定要退出登录吗？', function () {
                window.location.href = href;
            });
            return false;
        });
        if (!('placeholder' in document.createElement('input'))) {
            $('input[placeholder],textarea[placeholder]').each(function () {
                var that = $(this),
                text = that.attr('placeholder');
                if (that.val() === "") {
                    that.val(text).addClass('placeholder');
                }
                that.focus(function () {
                    if (that.val() === text) {
                        that.val("").removeClass('placeholder');
                    }
                })
                .blur(function () {
                    if (that.val() === "") {
                        that.val(text).addClass('placeholder');
                    }
                })
                .closest('form').submit(function () {
                    if (that.val() === text) {
                        that.val('');
                    }
                });
            });
        }
    });
</script>
</body>
</html>

